﻿CREATE PROCEDURE [acms].[Post_GetById]
	@SiteId int,
	@Id int,
	@SiteVersion DateTime
AS

	declare @tmp datetime

	set @tmp = acms.GetPublishDate(@SiteId, @SiteVersion)
	
	if(@tmp is null and @SiteVersion is not null)
		return
	
	
	SELECT a.*, b.[ParentPath] as ParentPath, b.PublishDate as SiteVersion
	FROM Post_View a 
		inner join PostPositions b on a.Id = b.PostId and isnull(b.PublishDate, '9999/12/31') = isnull(@tmp, '9999/12/31')
	Where a.Id = @Id

RETURN 0;